package com.yic.module.wms.dal.mysql.receiveapply;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.wms.dal.dataobject.receiveapply.ReceiveApplyDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.wms.controller.admin.receiveapply.vo.*;

/**
 * 领料申请单 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ReceiveApplyMapper extends BaseMapperX<ReceiveApplyDO> {

    default PageResult<ReceiveApplyDO> selectPage(ReceiveApplyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReceiveApplyDO>()
                .eqIfPresent(ReceiveApplyDO::getCode, reqVO.getCode())
                .eqIfPresent(ReceiveApplyDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ReceiveApplyDO::getWorkshopId, reqVO.getWorkshopId())
                .eqIfPresent(ReceiveApplyDO::getCenterId, reqVO.getCenterId())
                .eqIfPresent(ReceiveApplyDO::getMoId, reqVO.getMoId())
                .eqIfPresent(ReceiveApplyDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ReceiveApplyDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(ReceiveApplyDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(ReceiveApplyDO::getLocationId, reqVO.getLocationId())
                .eqIfPresent(ReceiveApplyDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ReceiveApplyDO::getBatchNo, reqVO.getBatchNo())
                .betweenIfPresent(ReceiveApplyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReceiveApplyDO::getId));
    }

    default List<ReceiveApplyDO> selectList(ReceiveApplyExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ReceiveApplyDO>()
                .eqIfPresent(ReceiveApplyDO::getCode, reqVO.getCode())
                .eqIfPresent(ReceiveApplyDO::getFactoryId, reqVO.getFactoryId())
                .eqIfPresent(ReceiveApplyDO::getWorkshopId, reqVO.getWorkshopId())
                .eqIfPresent(ReceiveApplyDO::getCenterId, reqVO.getCenterId())
                .eqIfPresent(ReceiveApplyDO::getMoId, reqVO.getMoId())
                .eqIfPresent(ReceiveApplyDO::getItemId, reqVO.getItemId())
                .eqIfPresent(ReceiveApplyDO::getWarehouseId, reqVO.getWarehouseId())
                .eqIfPresent(ReceiveApplyDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(ReceiveApplyDO::getLocationId, reqVO.getLocationId())
                .eqIfPresent(ReceiveApplyDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ReceiveApplyDO::getBatchNo, reqVO.getBatchNo())
                .betweenIfPresent(ReceiveApplyDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReceiveApplyDO::getId));
    }

}
